Site.GetState Method [IIS 7 and higher]
Returns the run-time state of a Web site.
Syntax
objSite.GetState
var siteState = objSite.GetState();
Parameters
This method takes no parameters.
Return Value
A uint32 that identifies the Web site state. The return values are shown in the following table.
Return value |
Description |
---|---|
0 |
Indicates that the Web site is starting. |
1 |
Indicates that the Web site has started. |
2 |
Indicates that the Web site is stopping. |
3 |
Indicates that the Web site has stopped. |
4 |
Indicates that the Web site state is unknown. |
Example
The following example gets the state of a Web site and returns it to the user.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Specify the Web site.
Set oSite = oWebAdmin.Get("Site.Name='IISWebSite'")
' Get the Web site's state and return it to the user by
' calling a helper function.
WScript.Echo oSite.Name & " is " & GetStateDescription(oSite.GetState) & "."
' The helper function translates the return value into text.
Function GetStateDescription(StateCode)
Select Case StateCode
Case 0
GetStateDescription = "Starting"
Case 1
GetStateDescription = "Started"
Case 2
GetStateDescription = "Stopping"
Case 3
GetStateDescription = "Stopped"
Case 4
GetStateDescription = "Unknown"
Case Else
GetStateDescription = "Attempt to retrieve state failed."
End Select
End Function
Requirements
Type |
Description |
---|---|
Client |
Requires IIS 7 on Windows Vista. |
Server |
Requires IIS 7 on Windows Server 2008. |
Product |
IIS 7 |
MOF file |
WebAdministration.mof |